DEFINE VARIABLE tax-rate AS DECIMAL.
DEFINE VARIABLE tax-amt AS DECIMAL.
DEFINE VARIABLE std-cost AS DECIMAL.

FOR EACH ptp_det EXCLUSIVE WHERE ptp_part BEGINS "P" AND ptp_pm_code = "m" ,
    EACH pt_mstr NO-LOCK WHERE ptp_part = pt_part AND can-do("FG-A,FG-B",pt_part_type) :
    
    FOR EACH hbc_hist WHERE hbc_site = "500" AND hbc_root = ptp_part NO-LOCK BREAK BY hbc_root:
        ACCUMULATE hbc_std_cost * hbc_sub_qty (TOTAL).
        ACCUMULATE hbc_tax_pct * hbc_sub_qty (TOTAL) .
        ACCUMULATE hbc_user2 (MAX) .
    END.
    
    tax-amt = ACCUM TOTAL hbc_tax_pct * hbc_sub_qty.  
    std-cost = ACCUM TOTAL hbc_std_cost * hbc_sub_qty. 
    tax-rate = tax-amt / std-cost.
    
    IF ABS(tax-rate - ptp__dec01) > 0.00001 THEN DO:
     ASSIGN ptp__dec01 = tax-rate.    
/*     ASSIGN ptp__dec02 = 0.           */

/*        DISP ptp_site FORMAT "X(6)"       */
/*          ptp_part                        */
/*          ptp__dec01 FORMAT ">>>>9.9<<<<" */
/*          ptp__dec02 FORMAT ">>>>9.9<<<<" */
/*          tax-rate   FORMAT ">>>>9.9<<<<" */
/*          tax-amt                         */
/*          std-cost                        */
/*          pt_desc1                        */
/*          ptp_pm_code                     */
/*          pt_part_type                    */
/*          pt_added                        */
/*          pt_userid                       */
/*          ACCUM MAX hbc_user2             */
/*                                          */
/*        WITH WIDTH 150.                   */
    END.
END.
